-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity docs #171
base: main
Are you sure you want to change the base?
Entity docs #171
Conversation
Co-authored-by: Dennis C <[email protected]>
Co-authored-by: Dennis C <[email protected]>
Co-authored-by: ChampionAsh5357 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass over the changes, still have to do the 4 largest files.
EntityRenderer-->ArrowRenderer; | ||
EntityRenderer-->LivingEntityRenderer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityRenderer-->ArrowRenderer; | |
EntityRenderer-->LivingEntityRenderer; | |
EntityRenderer-->LivingEntityRenderer; | |
EntityRenderer-->ArrowRenderer; |
These should be switched around to avoid the arrow from LivingEntityRenderer
to ArmorStandRenderer
going through the ArrowRenderer
node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this makes the arrow go through the AbstractMinecartRenderer
instead. I'm afraid there is no easy way of solving this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the requested feedback. Still a few WIP sections, so I'm wondering why it was brought out of draft early.
@@ -120,6 +120,7 @@ graph TD; | |||
PlayerEvent-->CanPlayerSleepEvent; | |||
|
|||
class Event,BlockEvent,EntityEvent,LivingEvent,PlayerEvent red; | |||
class BlockDropsEvent,CanPlayerSleepEvent blue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this in an entity docs PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly because this is the first PR that really makes use of Mermaid diagrams. I adopted the style guide of red -> abstract, blue -> non-abstract, and applied it to the only other diagram we had while I was at it.
docs/entities/livingentity.md
Outdated
Natural spawning is performed every tick for entities where `MobCategory#isFriendly()` is true, and every 400 ticks (\= 20 seconds) for entities where `MobCategory#isFriendly()` is false. If `MobCategory#isPersistent()` returns true, this process additionally also happens on chunk generation. | ||
|
||
For each chunk and mob category, it is checked whether there are less than `MobCategory#getMaxInstancesPerChunk() * loadedChunks / 289` in the world. Additionally, for each chunk, it is required that there are less than `MobCategory#getMaxInstancesPerChunk()` entities of that `MobCategory` near at least one player (near means that the distance between mob and player \<\= 128) for spawning of that `MobCategory` to occur. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be best to frame this with an example to get the actual numbers for each.
@IchHabeHunger54, this pull request has conflicts, please resolve them for this PR to move forward. |
# Conflicts: # docs/resources/client/models/bakedmodel.md # docs/resources/server/conditions.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I give you...more comments!
```java | ||
// This will return the tool's mining speed, or 1 if the held item is either empty, not a tool, | ||
// or not applicable for the block being broken. | ||
float destroySpeed = item.getDestroySpeed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this takes in the BlockState
to determine the destroy speed.
if (player.hasEffect(MobEffects.DIG_SPEED)) { destroySpeed *= ...; } | ||
if (player.hasEffect(MobEffects.CONDUIT_POWER)) { destroySpeed *= ...; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is partially wrong. It applies the maximum amplifier from dig speed and conduit power before doing some math stuff.
| `nametag_distance` | `NAMETAG_DISTANCE` | `[0,32]` | 32 | How far the nametag of the entity will be visible, in blocks. | | ||
| `swim_speed` | `SWIM_SPEED` | `[0,1024]` | 1 | A movement speed multiplier that is applied when the entity is underwater. This is applied independently from `minecraft:water_movement_efficiency`. | | ||
|
||
## Default Attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should also include the EntityAttributeModificationEvent
for adding new attributes to existing entities.
And that's it! Just don't forget to register your `DeferredRegister` to the mod bus, and off you go. | ||
|
||
:::info | ||
We use `Holder<Attribute>` here, instead of `Supplier<RangedAttribute>` like with many other registered objects, as it makes working with entities a lot easier (most entity methods expect `Holder<Attribute>`s). If, for some reason, you need a `Supplier<RangedAttribute>` (or a supplier of any other subclass of `Attribute`), you should use `DeferredHolder<Attribute, RangedAttribute>` as the type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify to use the explicit type you're using, since not everyone would use the RangedAttribute
.
if (renderer != null) { | ||
// Add the layer to the renderer. Like above, construct a new MyRenderLayer. | ||
// The EntityModelSet can be retrieved from the event through #getEntityModels. | ||
renderer.addLayer(new MyRenderLayer(renderer, event.getEntityModels())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not compile due to the generics.
// Get the associated PlayerRenderer. | ||
if (event.getSkin(skin) instanceof PlayerRenderer playerRenderer) { | ||
// Add the layer to the renderer. | ||
playerRenderer.addLayer(new MyRenderLayer(playerRenderer, event.getEntityModels())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not compile due to the generics differing between the layer and the renderer.
|
||
## Animations | ||
|
||
NeoForge adds an optional system that allows entity animations to be defined in JSON files, similar to third-party libraries such as [GeckoLib][geckolib]. Animations are defined in JSON files located at `assets/<namespace>/neoforge/animations/entity/<path>.json` (so for the [resource location][rl] `examplemod:example`, the file would be located at `assets/examplemod/neoforge/animations/entity/example.json`). The format of an animation file is as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically not a complete NeoForge system. Animation definitions is a vanilla system for animations using keyframes and interpolation data. What NeoForge adds is the ability is to define these via JSON. That might be what this sentence is saying, but it's a bit confusing.
{ | ||
// The name of the part to be animated. | ||
// Must match the name of a part defined in your LayerDefinition (see above). | ||
"bone": "head", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are multiple matches, it will just pick the first one it finds, which will always be a depth-first search iirc.
// A list of keyframes for the part. | ||
"keyframes": [ | ||
{ | ||
// The timestamp of the keyframe. Should be between 0 and the animation length. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timestamp is also in seconds.
Adds some long-needed entity documentation. Supersedes #15 and #95 . Closes #90 . This PR:
Preview URL: https://pr-171.neoforged-docs-previews.pages.dev